//品牌管理模块的接口

import request from '@/utils/request'
import { ListData, trademark } from './type'

enum API {
  TRADEMARK_LIST = '/admin/product/baseTrademark/',
  TRADEMARK_ADD = '/admin/product/baseTrademark/save',
  TRADEMARK_UPDATE = '/admin/product/baseTrademark/update',
  TRADEMARK_DELETE = '/admin/product/baseTrademark/remove/',
}

export const trademarkList = (page: number, limit: number) =>
  request.get<any, ListData>(API.TRADEMARK_LIST + `${page}/${limit}`)

export const addOrUpdate = (data: trademark) => {
  if (data.id) {
    return request.put<any, any>(API.TRADEMARK_UPDATE, data)
  } else {
    return request.post<any, any>(API.TRADEMARK_ADD, data)
  }
}

export const deleteTrademark = (id: number) => {
  return request.delete<any, any>(API.TRADEMARK_DELETE + id)
}
